# -*- coding:utf-8 -*-
"""
作者：xiaolu
日期：2022年09月24日
"""
from selenium import webdriver
import time
from selenium.webdriver.common.keys import Keys


# 获得浏览器的驱动
# driver = webdriver.Chrome()
# 键盘快捷键
# driver.get("http://127.0.0.1:88/zentao/user-login-L3plbnRhby8=.html")
# time.sleep(1)
# driver.maximize_window()
# time.sleep(1)
# # driver.find_element_by_id("account").clear()
# driver.find_element_by_id("account").send_keys("admin")
# time.sleep(1)
# driver.find_element_by_id("account").send_keys(Keys.TAB)
# driver.find_element_by_name("password").send_keys("200067Lxy")
# time.sleep(1)
# driver.find_element_by_name("password").send_keys(Keys.ENTER)
# time.sleep(3)
# driver.quit()




# 打开需要访问的web页面
# driver.get("https://www.baidu.com/")

# 打印标题
# title = driver.title
# print(title)

# 打印链接
# url = driver.current_url
# print(url)

# text = driver.find_element_by_id("bottom_layer").text
# text = driver.find_element_by_partial_link_text("贴").text
# print(text)
# time.sleep(2)
# driver.quit()

# 用css selector来定位元素
# driver.find_element_by_css_selector("#kw").send_keys("李白")
# driver.find_element_by_css_selector("#su").click()
# time.sleep(3)
#
# # 浏览器的前进和后退
# time.sleep(3)
# driver.back()
# time.sleep(3)
# driver.forward()

# 设置浏览器的大小
# driver.set_window_size(500, 1000)
# 浏览器的最大化
# driver.maximize_window()

# # 清除浏览器的内容
# driver.find_element_by_css_selector("#kw").clear()
# driver.find_element_by_css_selector("#kw").send_keys("杜甫")
# driver.find_element_by_css_selector("#su").click()
# time.sleep(8)
# driver.quit()

# 用xpath来定位元素
# driver.find_element_by_xpath("//*[@id='kw']").send_keys("C语言")
# driver.find_element_by_xpath("//*[@id='su']").click()

# 用ID定位
# driver.find.element_by_id("kw").send_keys("python")
# driver.find.element_by_id("su").click()

# 用name定位
# driver.find.element_by_name("wd").send_keys("java")
# driver.find.element_by_id("su").click()
# driver.find_element_by_link_text("新闻").click()

# 页面右边的滚轴操作
# driver.find_element_by_partial_link_text("新").click()
# js0 = "var q=document.documentElement.scrollTop=10000"
# driver.execute_script(js0)
# time.sleep(2)
# ji1 = "var q=document.documentElement.scrollTop=0"
# driver.execute_script(ji1)
# time .sleep(3)
# driver.quit()
